/*
 * Robust Pointers - A framework for robust pointers in a MT environment.
 * http://code.google.com/p/rptr/
 *
 * Copyright (c) 2009, Bill K. Barekas <bbarekas@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *    1. Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *    2. Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *    3. Neither the name of the author nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * @file    rptr.h
 * @author  Bill K. Barekas <bbarekas@gmail.com>
 * @date    October 3, 2009
 * @version $Id$
 *
 * This file contains the declarations for the main functions and helper
 * data structures of the Robust PoinTeR library.
 */


#ifndef RPTR_H_
#define RPTR_H_

#include <stdint.h>
#include <stdarg.h>


/**
 * Exported types definitions
 */

typedef void *     rptr;
typedef uint32_t   rptr_type;


/**
 * rptr configuration structure.
 */
typedef struct rptr_conf_t {
  uint32_t         flags;               /* RPTR support flags. */
  uint32_t         min_objs;            /* Minimum RPTR objects. */
  uint32_t         max_objs;            /* Maximum RPTR objects. */
  uint32_t         inc_step;            /* Maximum RPTR objects. */
  uint32_t         reuse_period;        /* Free object reuse period. */
} rptr_conf;


/**
 * Exported functions
 */

int rptr_init(rptr_conf * conf);
rptr_type rptr_new_type(char * full_name, char * abbr_name, uint32_t size);
rptr rptr_add(rptr_type typeid, void * ptr, uint32_t id);
void rptr_delete(rptr ptr, int error);
uint64_t rptr_get_id(rptr ptr);
void * rptr_get_ptr(rptr ptr, rptr_type type);
void rptr_stats(char * str);


#endif  /* RPTR_H_ */
